/**
 * Licensed under the Apache License Version 2.0.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package net.interknit.knitter.fw.util;

import java.io.File;

public class FrameworkUtils
{
	public static String[] getFilePrefixSuffix(File file)
	{
		return getFilePrefixSuffix(file.getAbsolutePath());
	}

	public static String[] getFilePrefixSuffix(String path)
	{
		String[] presuff = new String[] { "", "" };

		path = path.replace('\\', '/');
		int lastSlash = path.lastIndexOf('/');

		String fname = lastSlash > -1 ? path.substring(lastSlash + 1) : path;

		int lastDot = fname.lastIndexOf('.');

		presuff[0] = lastDot > -1 ? fname.substring(0, lastDot) : fname;
		presuff[1] = lastDot > -1 ? fname.substring(lastDot + 1) : "";

		return presuff;
	}
}
